package com.es.commons.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;

/**
 * 描述:
 * Old-AgeCareSystem-
 *
 * @author Derek
 * @create 2021-12-07 11:27
 */
@Configuration
public class RedisConfigurer {

    @Bean
    public RedisTemplate redisTemplate(RedisConnectionFactory redisConnectionFactory){

        RedisTemplate<String,Object> redisTemplate = new RedisTemplate<>();
        redisTemplate.setConnectionFactory(redisConnectionFactory);
        Jackson2JsonRedisSerializer<String> redisSerializer = new Jackson2JsonRedisSerializer(Object.class);
      //  StringRedisSerializer stringSerializer = new StringRedisSerializer();
        redisTemplate.setDefaultSerializer(redisSerializer);
        return redisTemplate;

    }
}
